﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DBEngine.Elements
{
    class ExaminationElement
    {
        internal enum Fields { OD, OS };
        private double mODValue;
        private double mOSValue;

      
        internal double this[Fields field]
        {
            get
            {
                double retval = 0;
                switch (field)
                {
                    case Fields.OD: retval = mODValue; break;
                    case Fields.OS: retval = mOSValue; break;
                }
                return retval;
            }
            set
            {
                switch (field)
                {
                    case Fields.OD: mODValue = Convert.ToDouble(value); break;
                    case Fields.OS: mOSValue = Convert.ToDouble(value); break;
                }
            }
        }
       

    }

    abstract class Examination : Element 
    {
        internal enum Fields { SPHERE, CYLINDER, AXIS, PRISM, BASE, ADD, H, PD, BC, DIA, KR, Date, ID, ClientID };
        private DateTime mDate;
        int mClientID;
        private Dictionary<Enum, ExaminationElement> mExaminationValues;

        protected Examination() { }
        protected Examination(DateTime mDate,int mClientID,Dictionary<Enum, ExaminationElement> mExaminationValues)
        {
            this.mDate = mDate;
            this.mClientID = mClientID;
            this.mExaminationValues = new Dictionary<Enum, ExaminationElement>(mExaminationValues);
        }

        internal Object this[Fields field]
        {
            get
            {
                Object retval = null;
                switch (field)
                {
                    case Fields.ID:
                        retval = mID; break;

                    case Fields.ClientID:
                        retval = mClientID; break;

                    case Fields.Date:
                        retval = mDate; break;

                    default:
                        retval = mExaminationValues[field]; break;

                }
                return retval;
            }

            set
            {
                switch (field)
                {
                    case Fields.ID:
                        mID = Convert.ToInt16(value); break;

                    case Fields.ClientID:
                        mClientID = Convert.ToInt16(value); ; break;

                    case Fields.Date:
                        mDate = (DateTime)value; break;

                    default:
                        mExaminationValues[field] = ( (ExaminationElement)value); break;

                }
            }
        }

    }
    class GlasesExamination : Examination
    {
        internal GlasesExamination() { }
        internal GlasesExamination(DateTime mDate,int mClientID,Dictionary<Enum, ExaminationElement> mExaminationValues)
            : base( mDate, mClientID, mExaminationValues){}


    }

    class LensesExamination : Examination
    {
        internal LensesExamination() { }
         internal LensesExamination(DateTime mDate,int mClientID,Dictionary<Enum, ExaminationElement> mExaminationValues)
            : base( mDate, mClientID, mExaminationValues){}
    }

}
